<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/29
 * Time: 10:24
 */

namespace app\api\controller\v1;


use app\api\general\Konstanten;
use think\Controller;

class Index extends Controller implements Konstanten
{


    public function index()
    {
        foreach (xrange(1, 9, 2) as $number) {
            echo "$number ";
        }
        foreach (range(1, 9, 3) as $number) {
            echo "$number ";
        }
        $demo = $this->demo();
        echo $demo->key();
        echo $demo->current();
        echo $demo->send('大海不知道痛苦!');

    }

    /**
     * @return \Generator
     * 预定义接口 --- 生成器类
     */
    public function demo(){
        yield 'demo'=>'loop';
    }


    public function ceshi(){
        $opts = array(
            'socket' => array(
                'bindto' => '0:7000',
            ),
        );
        //$context = stream_context_create($opts);
        //打开某一个网站
        //echo file_get_contents('http://www.baidu.com', false, $context);
        // 循环 ext/spl/examples/ 目录里所有 *.php 文件
        // 并打印文件名和文件尺寸
        $it = new \DirectoryIterator("glob://phpStudy/WWW/waibao/application/api/controller/v1/*.php");
        foreach($it as $f) {
            printf("%s: %.1FK\n", $f->getFilename(), $f->getSize()/1024);
        }
    }
}